﻿(*                  FnSharp              

   Base class library extensions and frameworks aimed 
   specifically at improving F# developers lives!

   Written by: Huw Simpson
   License: Microsoft Public License (Ms-PL) 
   Available at: http://fnsharp.codeplex.com

*)
namespace FnSharp.Bcl.Xml

    open System

    module LightDsl =
        type XmlMarkup =
            | Element of XmlElement
            | Attribute of XmlAttribute

        and XmlName =
            | Name of string
            | QualifiedName of string * string

        and XmlElement =
            {   Name:XmlName
                Attributes:XmlAttribute list
                Content:XmlElementContent }

        and XmlElementContent =
            | Empty
            | Value of string
            | Content of XmlElement list
            
        and XmlAttribute =
            {   Name:XmlName
                Value:String    }

        let name s = Name (s)
        let qname ns s = QualifiedName (ns, s)

        let (@=) name value = { Name=name; Value=value }
        let elem name = { Name=name; Attributes=[]; Content=Empty }
        let attribs a (el:XmlElement) = { el with Attributes=a }
        let value s (el:XmlElement) = { el with Content=Value (s) }
        let content items (el:XmlElement) = { el with Content=Content (items) }